import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { AuthClientWeb_Service } from './authClientWeb.service';
import { AuthClientWeb_SignIn_Dto, AuthClientWeb_WxChatLogin_Dto } from './assets/authClientWeb.dto';
import { ApiExtraModels, ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { AuthClientWeb_SignIn_ReClass } from './assets/authClientWeb.class';
import { util_Index_ReturnContent } from '@/common/util/index';

@Controller('/web/authClientWeb')
@ApiTags('authClientWeb 登录')
export class AuthClientWeb_Controller {
  constructor(private authClientWeb_Service: AuthClientWeb_Service) {}

  @Post('/signIn')
  @ApiExtraModels(AuthClientWeb_SignIn_ReClass)
  @util_ApiResponse_Base({
    dataType: 'dataType_object',
    status: 201,
    description: '登录成功',
    type: AuthClientWeb_SignIn_ReClass,
    //apiKey: '/web/authClientWeb/signIn Post',
    summary: '登录',
    noAuth: true,
  })
  async authClientWeb_SignIn(@Body() body: AuthClientWeb_SignIn_Dto) {
    return util_Index_ReturnContent(await this.authClientWeb_Service.authClientWeb_SignIn(body));
  }

  @Post('/wxLogin')
  @util_ApiResponse_Base({
    dataType: 'dataType_string',
    //apiKey: '/web/authClientWeb/wxLogin Post',
    status: 201,
    description: '返回授权地址',
    type: 'https://open.weixin.qq.com/connect/oauth2/...',
    summary: '获取微信授权地址',
    noAuth: true,
  })
  async authClientWeb_WechatRedirectUrl(@Body() body: AuthClientWeb_WxChatLogin_Dto) {
    return util_Index_ReturnContent(
      this.authClientWeb_Service.authClientWeb_WechatRedirectUrl(body.redirectUri),
    );
  }

  @Get('/wechatUserInfo')
  @util_ApiResponse_Base({
    dataType: 'dataType_object',
    status: 201,
    description: '返回用户信息',
    type: AuthClientWeb_SignIn_ReClass,
    //apiKey: '/web/authClientWeb/wechatUserInfo Get',
    summary: '获取用户信息',
    noAuth: true,
  })
  async authClientWeb_WechatUserInfo(@Query('code') code: string) {
    return util_Index_ReturnContent(await this.authClientWeb_Service.authClientWeb_WechatUserInfo(code));
  }
}
